package tool;

import org.junit.Test;

import java.io.File;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;

public class IOUtilTest {
    /*
    单字节传输
     */
    @Test
    public void copyFileByByte() {
        IOUtil ioUtil = new IOUtil();
        long start = System.currentTimeMillis();
        ioUtil.copyFileByByte(new File("D:\\tools\\1.mp4"),new File("D:\\tools\\2.mp4"));
        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }
    /*
    批量传输
     */
    @Test
    public void copyFileByArray() {

        long start = System.currentTimeMillis();
        IOUtil ioUtil = new IOUtil();
        ioUtil.copyFileByArray(new File("D:\\tools\\1.mp4"),new File("D:\\tools\\5.mp4"));
        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }

    /*
    缓冲copy
     */
    @Test
    public void fileCopyByBuffer() {
        long start = System.currentTimeMillis();
        IOUtil ioUtil = new IOUtil();
        ioUtil.fileCopyByBuffer(new File("D:\\tools\\1.mp4"),new File("D:\\tools\\6.mp4"));
        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }


    @Test
    public void test066() throws UnknownHostException {
        InetAddress address = InetAddress.getLocalHost();
        System.out.println(address.getHostName());
        System.out.println(address.getHostAddress());
        byte[] address1 = address.getAddress();
        System.out.println(Arrays.toString(address1));
        System.out.println("============"+address);

        InetAddress inetAddress = InetAddress.getByName("DESKTOP-AUJ1HB8");
        System.out.println(inetAddress.getHostName());
        System.out.println(inetAddress.getHostAddress());

    }

    @Test
    public void test077() throws Exception{


    }
}
